//
//  ClientApi.m
//  FinancialStore
//
//  Created by zhenqiu on 16/7/22.
//  Copyright © 2016年 zhenqiu. All rights reserved.
//

#import "ClientApi.h"
#import "RegiestDeviceNumber.h"
#import "CacheHelper.h"
#import "BillUserModel.h"
#import "BillUserEmailModel.h"

@implementation ClientApi


-(void)baseRequest:(id)action withParameters:(id)dic withCallBack:(nullable CompletionBlock)callBack{
    
    if([[EncryptAction getAuthDid] integerValue] == [AUTH_DID integerValue]){
        
        [RegiestDeviceNumber regiesterDevice:^(NSError *error) {
            if(error){
                
                callBack(nil,error);
                
            }else{
                
                [self requestWithUrl:action withParameters:dic withCompletion:callBack];
            }
            
        }   ];
        
    }else{
        
        [self requestWithUrl:action withParameters:dic withCompletion:callBack];
    }
    
}

-(void)baseRequest:(id)action withCallBack:(nullable CompletionBlock)callBack{
    
    [self baseRequest:action withParameters:nil withCallBack:callBack];
    
}


// special
// requestWithUrl
-(void)registerImei:(nullable id)parameter withCallBack:(nullable CompletionBlock) callBack {
    
    [self requestWithUrl:REGISTER_DEVICE_ACTION withParameters:parameter withCompletion:callBack];
}


-(void)registerPushCode:(nonnull NSString*)pushCode withCallBack:(nullable CompletionBlock) callBack{
    
    NSString * is_enterprise = @"1";
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:is_enterprise forKey:@"is_enterprise"];
    [dic setValue:pushCode forKey:@"pushCode"];
    [self baseRequest:REGISTER_PUSH_CODE_ACTION withParameters:dic withCallBack:callBack];
}


-(void)getXindaiZone:(NSInteger)letter withHot:(NSInteger)hot withCallBack:(nullable CompletionBlock) callBack{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:@(letter) forKey:@"letter"];
    [dic setValue:@(hot) forKey:@"hot"];
    [self baseRequest:GET_XINDAI_ZONE_ACTION withParameters:dic withCallBack:callBack];
    
}

-(void)getVerifyCode:(nonnull NSString*)mobile withTelid:(NSInteger)telid withUid:(NSInteger)uid withIsVerify:(NSInteger)isVerify withCallBack:(nullable CompletionBlock) callBack{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
    
    NSString * eMobile = [EncryptRequestAction encryptStr:mobile];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:@(telid) forKey:@"telid"];
    [dic setValue:@(0) forKey:@"is_verify_mobile"];
    
    [self baseRequest:GET_VERIFY_CODE_ACTION withParameters:dic withCallBack:callBack];
    
}
//登录或者快速登录
-(void)login:(nonnull NSString*)mobile withVerify:(NSInteger)is_login withChecksms:(nullable NSString*)checksms withPasswd:(nullable NSString*)passwd withCallBack:(nullable CompletionBlock) callBack{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:3];
    
    NSString * eMobile = [EncryptRequestAction encryptStr:mobile];
    if (is_login == 0) {
        [dic setValue:passwd forKey:@"passwd"];
    }else {
        [dic setValue:checksms forKey:@"checksms"];
    }
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:@(is_login) forKey:@"is_code_login"];
    
    [self baseRequest:LOGIN_ACTION  withParameters:dic withCallBack:callBack];
}
- (void)loginWithRegister:(nullable NSString *)phoneNumber withChecksms:(nullable NSString *)checksms withPasswd:(nullable NSString *)passwd withConfirmPasswd:(nullable NSString *)confirmPasswd withCallBack:(nullable CompletionBlock) callBack{
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:4];
    NSString * eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:checksms forKey:@"checksms"];
    [dic setValue:passwd forKey:@"passwd"];
    [dic setValue:confirmPasswd forKey:@"confirm_passwd"];
    [self baseRequest:LOGIN_REGISTER withParameters:dic withCallBack:callBack];
}

-(void)exit:(nullable CompletionBlock) callBack{
    
    NSString * userid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:userid forKey:@"uid"];
    [self baseRequest:EXIT_ACTION withParameters:dic withCallBack:callBack];
    
}

- (void)getCreditCardLineBanks:(NSInteger)show_nums withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:@(show_nums) forKey:@"show_nums"];
    [self baseRequest:GET_CREDITCARD_BANKLINE withParameters:dic withCallBack:callBack];
}

- (void)getCreditCardBanksWithCallBack:(nullable CompletionBlock)callBack{
    [self baseRequest:GET_CREDITCARD_BANKLINE withCallBack:callBack];
}

- (void)getCreditCardTagsWithCallBack:(nullable CompletionBlock)callBack{
    [self baseRequest:GET_CREDITCARD_TAGS withCallBack:callBack];
}

- (void)getCredtiCardListWithPage:(NSInteger)page andPageSize:(NSInteger)page_size andCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:@(page) forKey:@"page"];
    [dic setValue:@(page_size) forKey:@"page_size"];
    [dic setValue:@1 forKey:@"sugest"];
    [dic setValue:@1 forKey:@"online"];
    [self baseRequest:GET_CREDITCARD_LIST withParameters:dic withCallBack:callBack];
}


- (void)getCreditCardWithPage:(NSInteger)page andPageSize:(NSInteger)page_size andBankId:(NSInteger)bank_id
                   andTagsIds:(NSString *)tag_ids andKeyWord:(NSString *)keyword
                     andIsHot:(NSInteger)isHotCard
                  andCallBack:(nullable CompletionBlock)callBack{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:7];
    [dic setValue:@(page) forKey:@"page"];
    [dic setValue:@(page_size) forKey:@"page_size"];
    [dic setValue:@(isHotCard) forKey:@"sugest"];
    [dic setValue:@1 forKey:@"online"];
    [dic setValue:@(bank_id) forKey:@"bank_id"];
    if (tag_ids) {
        [dic setValue:tag_ids forKey:@"tag_ids"];
    }
    if (keyword) {
        [dic setValue:keyword forKey:@"keyword"];
    }
    GYNLog(@"====%@",dic);
    [self baseRequest:GET_CREDITCARD_LIST withParameters:dic withCallBack:callBack];
}


- (void)getCreditCardDetail:(NSInteger)card_id withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    id uuid = [[CacheHelper getInstance] getUserId];
    [dic setValue:@(card_id) forKey:@"card_id"];
    [dic setValue:uuid forKey:@"uid"];
    [self baseRequest:GET_CREDITCARD_DETAIL withParameters:dic withCallBack:callBack];
}

- (void)getCreditCardDetailNew:(NSInteger)card_id withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    id uuid = [[CacheHelper getInstance] getUserId];
    [dic setValue:@(card_id) forKey:@"card_id"];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(2) forKey:@"base_info"];
    [dic setValue:@(1) forKey:@"privileges_info"];
    [dic setValue:@(2) forKey:@"cost_info"];
    [self baseRequest:GET_CREDITCARD_DETAIL_NEW withParameters:dic withCallBack:callBack];
    
}


- (void)addCreditCardApplyRecordWithCard_id:(NSInteger)card_id withBank_id:(NSInteger)bank_id withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:@(card_id) forKey:@"card_id"];
    [dic setValue:@(bank_id) forKey:@"bank_id"];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:APP_NO forKey:@"app_no"];
    [dic setValue:CHANNEL forKey:@"channel"];
    [self baseRequest:ADD_USERCENTER_ADD_CARD_APPLY_RECORD withParameters:dic withCallBack:callBack];
}

- (void)getCreditCardApplyRecordWithCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:uuid forKey:@"uid"];
    [self baseRequest:GET_USERCENTER_ADD_CARD_APPLY_RECORD_LIST withParameters:dic withCallBack:callBack];
    
    
}
- (void)getMeInquireCardWithCallBack:(nullable CompletionBlock)callBack{
    [self baseRequest:GET_ME_CREDITCARD_INQUIRE withCallBack:callBack];
    
}

- (void)getMyloanWithCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:uuid forKey:@"uid"];
    [self baseRequest:GET_ME_MY_LOAN withParameters:dic withCallBack:callBack];
}

- (void)addFeedbackMsgWithModel:(FeedBackModel *)model andCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:model.content forKey:@"content"];
    [dic setValue:model.contact forKey:@"contact"];
    [dic setValue:model.qq forKey:@"qq"];
    if (model.weinxin.length > 0) {
        [dic setValue:model.weinxin forKey:@"weinxin"];
    }
    [self baseRequest:ADD_USER_FEEDBACK_MSG withParameters:dic withCallBack:callBack];
}


// bill
//bill
- (void)addBillCreditCardWith:(NSInteger)ID WithCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    BillUserModel *model = [BillUserModel getInstance];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:6];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(ID) forKey:@"id"];
    
    [dic setValue:model.bank_id forKey:@"bank_id"];
    [dic setValue:model.cardIDFour forKey:@"bank_num"];
    [dic setValue:model.limitCash forKey:@"card_limit"];
    [dic setValue:[BillUserModel getSubDate:model.billDate] forKey:@"statement_date"];
    [dic setValue:[BillUserModel getSubDate:model.repayDate] forKey:@"repayment_date"];
    [dic setValue:model.repayCash forKey:@"new_balance"];
    
    [self baseRequest:ADD_USERCENTER_ADD_BIND_CARD withParameters:dic withCallBack:callBack];
    
}

- (void)getBillCreditCardMyListWithlist:(NSInteger)has_list WithCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(has_list) forKey:@"has_list"];
    
    [self baseRequest:GET_ME_BILL_CREDITCARD_MYLIST withParameters:dic withCallBack:callBack];
    
}

- (void)getBillDetailHandWithCardID:(NSInteger)card_id withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(card_id) forKey:@"id"];
    [self baseRequest:GET_ME_BILL_DETAIL_HAND withParameters:dic withCallBack:callBack];
}


- (void)deleteBillHandWithID:(NSInteger)ID andIsSpider:(NSInteger)is_Spider withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(ID) forKey:@"id"];
    [dic setValue:@(is_Spider) forKey:@"is_spider_statement"];
    [self baseRequest:DELETE_ME_BILL_DETAIL_HAND withParameters:dic withCallBack:callBack];
}

- (void)getBillEmailList:(nullable CompletionBlock)callBack{
    [self baseRequest:GET_ME_BILL_EMAIL_LIST withCallBack:callBack];
}

- (void)addEmailBillWithType:(NSString *)bindType andCard_id:(NSInteger)card_id andCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    id uuid = [[CacheHelper getInstance] getUserId];
    if ([bindType isEqualToString:@"1"]) {
        [dic removeAllObjects];
        BillUserEmailModel *model = [BillUserEmailModel getInstance];
        [dic setValue:uuid forKey:@"uid"];
        [dic setValue:bindType forKey:@"is_bind_email"];
        [dic setValue:model.suffix forKey:@"suffix"];
        [dic setValue:model.username forKey:@"username"];
        [dic setValue:model.passwd forKey:@"passwd"];
    }else{
        [dic removeAllObjects];
        [dic setValue:bindType forKey:@"is_bind_email"];
        [dic setValue:@(card_id) forKey:@"card_id"];
        [dic setValue:uuid forKey:@"uid"];
    }
    [self baseRequest:ADD_USERCENTER_ADD_EMAIL_BILL withParameters:dic withCallBack:callBack];
}


- (void)getBillDetailSpiderWithCardID:(NSInteger)ID withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(ID) forKey:@"id"];
    [dic setValue:@1 forKey:@"is_read"];
    [self baseRequest:GET_ME_BILL_CARD_DETAIL_SPIDER withParameters:dic withCallBack:callBack];
}

- (void)getBillListSpiderPastWithCardID:(NSInteger)ID withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(ID) forKey:@"id"];
    [self baseRequest:GET_ME_BILL_LIST_SPIDER_PAST withParameters:dic withCallBack:callBack];
}

- (void)getBillMonthDetailWithCardID:(NSInteger)ID andNum:(NSString *)bank_num withCallBack:(nullable CompletionBlock)callBack{
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:3];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(ID) forKey:@"id"];
    [dic setValue:bank_num forKey:@"bank_num"];
    [self baseRequest:GET_ME_BILL_MONTH_DETAIL withParameters:dic withCallBack:callBack];
}

// loan
-(void)reuqestLoanWithDic:(nonnull id)dic withCallBack:(nullable CompletionBlock)callBack{
    
    NSMutableDictionary * fdic = [NSMutableDictionary dictionaryWithDictionary:dic];
    id uuid = [[CacheHelper getInstance] getUserId];
    [fdic setValue:uuid forKey:@"uid"];
    
    if([dic valueForKey:@"mobile"]){
        
        NSString * eMobile = [EncryptRequestAction encryptStr:[dic valueForKey:@"mobile"]];
        [fdic setValue:eMobile forKey:@"mobile"];
        
    }
    
    if([dic valueForKey:@"id_card"]){
        
        NSString * eId_card = [EncryptRequestAction encryptStr:[dic valueForKey:@"id_card"]];
        [fdic setValue:eId_card forKey:@"id_card"];
    }
    
    [self baseRequest:REQUEST_LOAN_ACTION withParameters:fdic withCallBack:callBack];
    
}

// banner

- (void)getDiscoverBannerWithType:(NSUInteger)bannerType cityName:(NSString *)cityName withCallBack:(nullable CompletionBlock)callBack{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:[NSString stringWithFormat:@"%zd",bannerType] forKey:@"banner_type"];
    if(cityName){
        [dic setValue:cityName forKey:@"city"];
    }
    [self baseRequest:GET_DISCOVER_TOP_BANNER withParameters:dic withCallBack:callBack];
}

- (void)getDiscoverHotNewsInfoWithCateID:(nullable NSString *)cate_id  cityName:(NSString *)cityName page:(NSInteger)loadPage  withCallBack:(nullable CompletionBlock)callBack{
    if(loadPage == 0){
        loadPage =1;
    }
    NSMutableDictionary * dic = [[NSMutableDictionary alloc] init];
    NSString * tempID =nil;
    if(cate_id){
        tempID =  [NSString stringWithFormat:@"%@",cate_id];
        [dic setValue:tempID forKey:@"cate_id"];
    }
    if(cityName){
        [dic setValue:cityName forKey:@"city"];
    }
    [dic setValue:[NSString stringWithFormat:@"%ld",(long)loadPage] forKey:@"pg_num"];
    
    [self baseRequest:GET_DISCOVER_HOTNEWSINFOLIST withParameters:dic withCallBack:callBack];
}

//请求短信验证码
- (void)getMeVerifyPhoneNumber:(nullable NSString *)phoneNumber withTeild:(NSInteger)telid withCallBack:(nullable CompletionBlock)callBack {
    NSString * eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    id uuid = [[CacheHelper getInstance] getUserId];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:@(telid) forKey:@"telid"];
    [dic setValue:eMobile forKey:@"mobile"];
    if (telid == 1) {
        [dic setValue:@(1) forKey:@"is_verify_mobile"];
    }else {
        if (uuid == nil) {
            
        }else {
            [dic setValue:uuid forKey:@"uid"];
        }
    }
    [self baseRequest:GET_ME_PHONENUMBER_VERIFY withParameters:dic withCallBack:callBack];
}

//修改密码
- (void)getMeVerifyPhoneNumber:(nullable NSString *)phoneNumber withChecksms:(nullable NSString *)checksms withPassWord:(nullable NSString *)passWord withConfirmPassWord:(nullable NSString *)confirmPassWord withCallBack:(nullable CompletionBlock)callBack {
    id uuid = [[CacheHelper getInstance] getUserId];
    NSString *eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    NSInteger verify_type = 0;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:7];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:@(verify_type) forKey:@"verify_type"];
    [dic setValue:checksms forKey:@"checksms"];
    [dic setValue:passWord forKey:@"passwd"];
    [dic setValue:confirmPassWord forKey:@"confirm_passwd"];
    [self baseRequest:GET_ME_PASSWORD_MODFIY withParameters:dic withCallBack:callBack];
}

//修改手机号
- (void)getMeModificationWithNewPhoneNumber:(nullable NSString *)phoneNumber withChecksms:(nullable NSString *)checksms withCallBack:(nullable CompletionBlock)callBack {
    id uuid = [[CacheHelper getInstance] getUserId];
    id oldPhoneNumbers = [[CacheHelper getInstance] getPhoneNumber];
    NSString * eMobile = [EncryptRequestAction encryptStr:oldPhoneNumbers];
    NSString * neweMobile = [EncryptRequestAction encryptStr:phoneNumber];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:neweMobile forKey:@"new_mobile"];
    [dic setValue:checksms forKey:@"checksms"];
    [self baseRequest:GET_ME_PHONENUMBER_MODIFICATION withParameters:dic withCallBack:callBack];
    
}

//忘记密码
- (void)forGotToLoginWithPhoneNumber:(nullable NSString *)phoneNumber withChecksms:(nullable NSString *)checksms withPasswd:(nullable NSString *)passwd withConfirmPasswd:(nullable NSString *)confirmPasswd withCallBack:(nullable CompletionBlock)callBack {
    id uuid = [[CacheHelper getInstance]getUserId];
    NSString *eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:5];
    if (uuid == nil) {
        
    }else {
        [dic setValue:uuid forKey:@"uid"];
    }
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:checksms forKey:@"checksms"];
    [dic setValue:passwd forKey:@"passwd"];
    [dic setValue:confirmPasswd forKey:@"confirm_passwd"];
    [self baseRequest:LOGIN_FORGOT withParameters:dic withCallBack:callBack];
}

//信用
- (void)CreditWithCommunication:(NSUInteger)communication withCallBack:(nullable CompletionBlock)callBack {
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
    id uuid = [[CacheHelper getInstance]getUserId];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(communication) forKey:@"category"];
    [self baseRequest:GET_CREDIT_INDIVIDUAL withParameters:dic withCallBack:callBack];
    
}

//上传认证信息
- (void)creditWithUpLoadWithSid:(NSInteger)sid WithAccount:(nullable NSString *)account WithData:(nullable NSString *)Datadic withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:4];
    id uuid = [[CacheHelper getInstance]getUserId];
    NSString *eAccount = [EncryptRequestAction encryptStr:account];
    NSString *eDataDic = [EncryptRequestAction encryptStr:Datadic];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(sid) forKey:@"sid"];
    [dic setValue:eAccount forKey:@"account"];
    [dic setValue:eDataDic forKey:@"auth_data"];
    [self baseRequest:GET_CREDIT_UPLOAD withParameters:dic withCallBack:callBack];
}
//上传邮箱信息
- (void)creditWithUpLoadEmailWithEmailUserName:(nullable NSString *)userName withPassWord:(nullable NSString *)passWord withSuffix:(nullable NSString *)suffix withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    id uuid = [[CacheHelper getInstance]getUserId];
    [dic setValue:@(1) forKey:@"authorized"];
    [dic setValue:userName forKey:@"username"];
    [dic setValue:passWord forKey:@"passwd"];
    [dic setValue:suffix forKey:@"suffix"];
    [dic setValue:uuid forKey:@"uid"];
    [self baseRequest:GET_CREDIT_UPLOAD_EMAIL withParameters:dic withCallBack:callBack];
}
//请求信用首页的全部数据
- (void)creditWithCreditHome:(nullable CompletionBlock)callBack {
    NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
    id uuid = [[CacheHelper getInstance]getUserId];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:@(0) forKey:@"category"];
    [self baseRequest:GET_CREDIT_INDIVIDUAL withParameters:dic withCallBack:callBack];
}
//验证短信验证码
- (void)verifyPhoneNumber:(nullable NSString *)phoneNumber withVerify:(nullable NSString *)verify withCallBlock:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:4];
    id uuid = [[CacheHelper getInstance]getUserId];
    NSString *eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:verify forKey:@"code"];
    [dic setValue:@(4) forKey:@"telid"];
    [self baseRequest:GET_ME_VERIGY_PHONE withParameters:dic withCallBack:callBack];
    
}

-(void)upLoadUserAvatar:(nonnull UIImage*)image withCallBack:(nullable CompletionBlock)callBack{
    
    NSData *imageData = UIImageJPEGRepresentation(image, 0.4);
    if(imageData){
        
        NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:2];
        [dic setValue:@"avatar" forKey:@"file_name"];
        [self requestWithUrl:USER_UPLOAD_AVATAR_ACTION withParameters:dic withFormData:imageData withCompletion:callBack];
    }
    
}

-(void)uploadUserImageInfo:(NSString*)sid withImage:(nonnull UIImage*)image withCallBack:(nullable CompletionBlock)callBack{
    
    NSData *imageData = UIImageJPEGRepresentation(image, 0.4);
    
    if(imageData){
        
        NSMutableDictionary * dic  = [NSMutableDictionary dictionaryWithCapacity:2];
        [dic setValue:sid forKey:@"sid"];
        [dic setValue:@"file" forKey:@"file_name"];
        //        [self requestWithUrl:USER_UPLOAD_IMAGE_ACTION withParameters:dic withFormData:imageData withCompletion:callBack];
        
        [self requestWithUrl:USER_UPLOAD_IMAGE_ACTION withParameters:dic withFormData:imageData withCompletion:^(id  _Nullable responseObject, NSError * _Nullable error) {
            
            if(error){
                
                callBack(responseObject,error);
            }else{
                id itemData = [responseObject valueForKey:@"items"];
                if(itemData){
                    
                    
                    NSString * url = [itemData valueForKey:@"file"];
                    NSString * de_url = [EncryptResponseAction decryptStr:url];
                    [itemData setValue:de_url forKey:@"file"];
                    callBack(responseObject,nil);
                    
                }
                
            }
            
        }];
    }
    
    
}

//上传考拉分数据
- (void)upLoadWithPhone:(nullable NSString *)phoneNumber withUserName:(nullable NSString *)userName withIdentityNumber:(nullable NSString *)identity withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    id uuid = [[CacheHelper getInstance]getUserId];
    NSString *eMobile = [EncryptRequestAction encryptStr:phoneNumber];
    NSString *eIdCard = [EncryptRequestAction encryptStr:identity];
    [dic setValue:uuid forKey:@"uid"];
    [dic setValue:eMobile forKey:@"mobile"];
    [dic setValue:userName forKey:@"realname"];
    [dic setValue:eIdCard forKey:@"id_card"];
    [dic setValue:@(1) forKey:@"authorized"];
    [self baseRequest:GET_CREDIT_UPLOAD_KALA withParameters:dic withCallBack:callBack];
}

//首页申请贷款、信用卡成功个数
- (void)getHomeApplyCardSuccessWithUnite:(nullable NSString *)unit size:(nullable NSString *)size withCallBack:(nullable CompletionBlock)callBack{
    NSMutableDictionary * param  =nil;
    if(unit){ unit = [NSString stringWithFormat:@"%@",unit];}
    if(size){ size = [NSString stringWithFormat:@"%@",size];}
    
    if(unit.length>0||size.length>0){
        param = [[NSMutableDictionary alloc] init];
        if(unit.length>0){
            [param setObject:unit forKey:@"unit"];
        }
        if(size.length>0){
            [param setObject:unit forKey:@"size"];
        }
    }
    
    [self baseRequest:GET_CREDITCARD_COUNT withParameters:param withCallBack:callBack];
}

-(void)checkAppCheckStatus:(nullable CompletionBlock) callBack{
  
  [self baseRequest:CHECK_APP_STATUS_ACTION withCallBack:callBack];
  
}

- (void)getLoanListH5Address:(nullable CompletionBlock)callBack{
  NSString *phoneNum = [[CacheHelper getInstance] getPhoneNumber];
  
  NSString * eMobile = [EncryptRequestAction encryptStr:phoneNum];
  NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
  [dic setValue:eMobile forKey:@"mobile"];
  [dic setValue:@"1" forKey:@"all_list"];
  [self baseRequest:GET_LOANLIST_H5_ADDRESS withParameters:dic withCallBack:callBack];
}

- (void)getTest:(nullable CompletionBlock)callBack{
  [self baseRequest:GET_TAB_CONTROL withParameters:@{@"is_default":@"1"} withCallBack:callBack];
}

- (void)checkAppVersionStatus:(NSDictionary *)params callback:(nullable CompletionBlock)callBack{
  [self baseRequest:CHEKC_APP_VERSION_ACTION withParameters:params withCallBack:callBack];
}


-(void)login:(nonnull NSString*)mobile withVerify:(NSInteger)is_login withChecksms:(nullable NSString*)checksms withPasswd:(nullable NSString*)passwd andIsJump:(NSInteger)is_jump withCallBack:(nullable CompletionBlock) callBack{
  
  NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:3];
  
  NSString * eMobile = [EncryptRequestAction encryptStr:mobile];
  if (is_login == 0) {
    [dic setValue:passwd forKey:@"passwd"];
  }else {
    [dic setValue:checksms forKey:@"checksms"];
  }
  if (is_jump == 1) {
    [dic setValue:@(is_jump) forKey:@"is_jump_code"];
  }
  [dic setValue:eMobile forKey:@"mobile"];
  [dic setValue:@(is_login) forKey:@"is_code_login"];
  
  [self baseRequest:LOGIN_ACTION  withParameters:dic withCallBack:callBack];
}

- (void)getArticleWithCate:(NSInteger)cate_id page:(NSInteger)page pageSize:(NSInteger)page_size withCallBack:(nullable CompletionBlock)callBack{
  NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithCapacity:3];
  if (page == 0) {
    page = 1;
  }
  if (page_size == 0) {
    page_size = 10;
  }
  if (cate_id && cate_id != 0) {
    [dic setValue:@(cate_id) forKey:@"cate_id"];
  }
  [dic setValue:@(page) forKey:@"pg_num"];
  [dic setValue:@(page_size) forKey:@"pg_size"];
  [self baseRequest:GET_DISCOVER_HOTNEWSINFOLIST withParameters:dic withCallBack:callBack];
  
}

- (void)getLoanBaoXianStatusWithCallBack:(nullable CompletionBlock)callBack{
  [self baseRequest:GET_LOAN_BAOXIAN_STATUS withCallBack:callBack];

}

- (void)getZQLoanListStatuWithCallBack:(nullable CompletionBlock)callBack{
  [self baseRequest:GET_LOAN_LIST_SHOW_STATUS withCallBack:callBack];

}



@end
